package controller

import (
	"api/app/mes/auto/v1/api"
	"api/config"
	sync "api/public/model-sync"
	"gitee.com/dreamwood/ez/server"
)

type TaskController struct {
	api.TaskApi
}

func init() {

	c := &TaskController{}
	c.Prepare()
	c.AddRoute("/list", c.ListAction)
	c.AddRoute("/get", c.GetAction)
	c.AddRoute("/scan", c.ScanAction)
	c.AddRoute("/choice", c.ChoiceAction)
	c.AddRoute("/save", c.SaveAction)
	c.AddRoute(`/save_many`, c.SaveManyAction)
	c.AddRoute("/delete", c.DeleteAction)
	c.AddRoute("/delete_many", c.DeleteManyAction)
	c.AddRoute("/copy", c.CopyAction)
	c.AddRoute("/sync", c.SyncAction)
}

//如果不满意自动生成的方法，请自定义，本文件不会被生成器覆盖，请放心操作
//func (this *TaskController) SaveAction(operation *server.Operation) {}
//func (this *TaskController) GetAction(operation *server.Operation) {}
//func (this *TaskController) ScanAction(operation *server.Operation) {}
//func (this *TaskController) ListAction(operation *server.Operation) {}
//func (this *TaskController) DeleteAction(operation *server.Operation) {}

func (c *TaskController) SyncAction(operation *server.Operation) {
	this := c.TakeOver(operation)
	if this.Try(sync.GetMS().PubInitNeed(config.GetService().Dependence["srcProduct"], "Product")) {
		return
	}
	this.ReturnSuccess("请求已发送，请稍后更新", "")
}
